﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using FeatureModelCore;
using FeatureModelCore.FMTypes;
using FeatureModelCore.FMInterface;

namespace FeatureModelTool.Windows
{
    /// <summary>
    /// Interaction logic for NewConstraintsDialog.xaml
    /// </summary>
    public partial class NewConstraintsDialog : Window
    {
        public bool Dirty { get; protected set; }
        public IFeature NodeA { get; protected set; }
        public IFeature NodeB { get; protected set; }
        public FMCrossTreeConstraintType ConstraintType { get; protected set; }

        public NewConstraintsDialog(IFeature[] nodes)
        {
            InitializeComponent();

            foreach (IFeature node in nodes)
            {
                this.nodeAComboBox.Items.Add(node);
                this.nodeBComboBox.Items.Add(node);
            }

            foreach (FMCrossTreeConstraintType type in 
                Enum.GetValues(typeof(FMCrossTreeConstraintType)))
            {
                this.typeComboBox.Items.Add(type);
            }
        }
        /// <summary>
        /// Ok Button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            
            if (this.nodeAComboBox.SelectedItem == null
                || this.nodeBComboBox.SelectedItem == null
                || this.typeComboBox.SelectedItem == null)
            {
                this.Close();
                return;
            }

            NodeA = (IFeature)this.nodeAComboBox.SelectedItem;
            NodeB = (IFeature)this.nodeBComboBox.SelectedItem;
            ConstraintType = (FMCrossTreeConstraintType)this.typeComboBox.SelectedItem;
            Dirty = true;
            this.Close();
        }
    }
}
